package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author MissChen
 * @date 2024年04月24日 10:01
 */

@WebServlet(urlPatterns = "/life2",loadOnStartup = 1,initParams = {
        @WebInitParam(name="name",value="coco"),
        @WebInitParam(name="password",value="123456")
})
public class LifeTwoServlet extends HttpServlet {
    @Override
    public void init() throws ServletException {
        System.out.println("*********注解版的初始方法***********");
        String name=getInitParameter("name");
        String password=getInitParameter("password");
        System.out.println("name:"+name+",password:"+password);


    }
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("执行核心业务逻辑");
    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("执行get请求");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("执行post请求");
    }



    @Override
    public void destroy() {
        System.out.println("正在销毁");
    }

}
